

class ISection{
    add(obj){};
    remove(obj){};
    getIterator(){};
}

class BusinessSection extends ISection{
    list = []
    add(obj){
        this.list.push(obj)
        return this
    };
    remove(obj){
        this.list = this.list.filter(v=>{v!==obj})
    };
    getIterator(){
        return new ConcreteIterator(this.list)
    };
}

/***
 * 迭代器接口
 */
class Iterator{
    hasNext(){

    }
    next(){
        
    }
    first(){
        
    }
}

/***
 * 具体迭代器
 */
class ConcreteIterator extends Iterator{
    index = -1
    constructor(list){
        super()
        this.list = list
    }
    hasNext(){
        if(this.index<this.list.length-1){
            return true
        }
        return false
    }
    next(){
        if(this.hasNext()){
            return this.list[++this.index]
        }
        return null
    }
    first(){
        this.index = 0
        return this.list[this.index]
    }
}

const section = new BusinessSection()
.add("科技管理部").add("科技产品部").add("财富事业部")
.add("生态金融").add("大数据部").add("人力资源部").add("合规部")
.add("小微金融事业部").add("汽车金融事业部").add("消费金融事业部")

const it = section.getIterator()

while(it.hasNext()){
    console.log(it.next())
}